<?php
require("../dbhead.php");

$data = array('name', 'society', 'description');

foreach ($data as $key) {
	if (array_key_exists($key, $_POST) && $_POST[$key] != '') {
		$$key = $_POST[$key];
	} else {
		header("Location: workshop_register_form.php");	// 에러 메시지를 GET으로 넘기기!
	}
}

// Check variables

if ($name == "" or $society == "" or $description == "")
	echo "Back!"; // Error

// Insert user data

$query = "INSERT INTO workshop_list (name, sid, description) values ('" . addslashes($name) . "', '${society}', '" . addslashes($description) . "')";
$row = mysql_query($query) or dberr($connect, $query, __LINE__);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
	<head>
		<title>EMRS sign up page</title>
		<link rel="stylesheet" type="text/css" href="../css/default.css" />
	</head>
	<body>
		<div>등록되었습니다.</div>
		<div><a href="../">Home</a></div>
	</body>
</html>